import time

# 方法1
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote.switch_to import SwitchTo

# 引入wait
from selenium.webdriver.support.ui import WebDriverWait

wd = webdriver.Chrome(service=Service(".\chromedriver_win136.exe"))
wd.get("http://127.0.0.1:5000/elements/")

# 先定位元素
element = wd.find_element(By.ID, "volumeValue")
print(element.text)  # 打印元素的文本内容
# 等待该元素的文本从 "50" 变成其他内容
WebDriverWait(wd, 10).until(lambda d: d.find_element(By.ID, "volumeValue").text != "50")

print("文本已改变，继续执行")
